﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace HY_Model
{
    /// <summary>
    /// 该类主要用于检测网络是否连通
    /// </summary>
    class ConnetNet
    {

    }
    public class ConnectNet
    {
        /// <summary>
        /// 该类主要用于检测网络是否连通，调用系统自带的API函数wininet.dll
        /// 使用该dll内的InternetGetConnectedState方法
        /// </summary>
        /// <param name="connnectionDescription">方法参数一,表示网络连接状态</param>
        /// <param name="reservedValue">方法参数2，保留参数</param>
        /// <returns>state ，类型为Bool</returns>
        [DllImport("wininet.dll")]
        private extern static bool InternetGetConnectedState(out int connnectionDescription, int reservedValue);


        public bool IsConnected()
        {
            int i = 0;
            bool state = InternetGetConnectedState(out i, 0);
            return state;

        }


    }
}
